<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
		<link rel="stylesheet" href="../../../css/common.css" media="all">

	</head>

	<body>

		<div class="layui-fluid reporting_style">
			<div class="layui-row" id="view">
				<form class="layui-form test_edit" lay-filter="test_detail" id="fo">
					<div class="layui-card">

						<div class="layui-card-body">
							<div class="layui-form-item">
								<label class="layui-form-label">项目：</label>
								<div class="layui-input-inline">
									<input type="text" readonly name="project_name" lay-verify="required" value="立刷伙伴" placeholder="" autocomplete="off" class="layui-input project_name">
									<input type="hidden" name="projectid" value="LSHB" placeholder="" autocomplete="off" class="layui-input projectid">
								</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">应用：</label>
								<div class="layui-input-inline">
									<input type="text" readonly name="app_name" placeholder="请选择应用" autocomplete="off" class="layui-input app_name">
									<input type="hidden" name="appid" placeholder="" autocomplete="off" class="layui-input appid">
								</div>
								<div class="layui-form-mid layui-word-aux">
									<a href="Javascript:;" onclick="check()">选择</a>
								</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">任务紧急程度：</label>
								<div class="layui-input-block work_order_level"></div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">工时(小时)：</label>
								<div class="layui-input-inline">
									<input type="number" placeholder="工时(小时)" class="layui-input" name="hours" lay-verify="hours" autocomplete="off">
								</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">费用：</label>
								<div class="layui-input-inline">
									<input type="number" placeholder="费用" class="layui-input" name="fee" lay-verify="" autocomplete="off">
								</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">预计完成时间：</label>
								<div class="layui-input-inline">
									<input type="text" class="layui-input" name="scheduled_time" autocomplete="off" id="test5" placeholder="预计完成时间">
								</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">问题描述：</label>
								<div class="layui-input-block">
									<textarea class="layui-textarea layui-hide" name="problem_desc" lay-verify="content" id="demo_editor"></textarea>
								</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">备注：</label>
								<div class="layui-input-block">
									<textarea class="layui-textarea" name="notes" lay-verify="" autocomplete="off"></textarea>
								</div>
							</div>

						</div>
					</div>

					<div class="layui-form-item layui-layout-admin">
						<div class="layui-input-block">
							<div class="layui-footer" style="left: 0;">
								<button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
							</div>
						</div>
					</div>

				</form>
			</div>
		</div>
		<script src="../../../layuiadmin/layui/layui.js"></script>
		<script src="../../../js/jquery.min.js"></script>
		<script src="../../../js/jquery.jqprint-0.3.js"></script>
		<script src="../../../js/common.js"></script>
		<script>
			var _data = {
				id: getParam('id')
			}

			layui.config({
				base: '../../../layuiadmin/' //静态资源所在路径
			}).extend({
				tinymce: 'tinymce/tinymce',
				index: 'lib/index' //主入口模块
			}).use(['tinymce', 'index', 'form', 'laytpl', 'laydate'], function() {
				var $ = layui.$,
					admin = layui.admin,
					laytpl = layui.laytpl,
					laydate = layui.laydate,
					tinymce = layui.tinymce,
					form = layui.form;
				map_show({
					mapName: 'work_order_level',
					domType: 'radio',
					fieldName: 'level'
				})

				if(getParam('id')) {
					loading();
					initdata();
				}

				var edit = tinymce.render({
					elem: "#demo_editor",
					height: 600
				});

				//日期时间选择器
				laydate.render({
					elem: '#test5',
					type: 'datetime'
				});
				//监听提交
				form.on('submit(demo1)', function(data) {
					var data = data.field;
					_data = Object.assign(_data, data);

					layer.confirm('确定要提交数据？', function() {
						loading();
						_data.problem_desc = edit.getContent()
						if(_data.id) {
							submitdata(wd_server.erp_work_order_edit);
						} else {
							delete _data.id;
							submitdata(wd_server.erp_work_order_insert);
						}
					}, function() {
						layer.msg('取消操作');
					});

					return false;
				});

				function submitdata(_url) {
					$.post(_url, _data, function(res, status) {
						if(status == 'success') {
							if(res.code == 0) {
								layer.alert(res.msg, function() {
									parent.layer.closeAll();
									parent.layui.table.reload('test-table-operate');
								});
							} else {
								layer.msg(res.msg);
							}
							closeloading();
						} else {
							closeloading();
							layer.msg('服务器连接错误');
						}
					});
				}

				function initdata() {
					$.get(wd_server.erp_work_order_detail, _data, function(res, status) {
						if(status == 'success') {
							if(res.code == 0) {
								var data = res.erp_work_order
								form.val("test_detail", data.data);
								form.render();
							} else {
								layer.msg(res.msg);
							}
							layer.closeAll('loading')
						} else {
							layer.msg('服务器连接错误');
							layer.closeAll('loading')
						}
					});
				}

				window.check = function() {
					layer.open({
						type: 2,
						title: '选择',
						shadeClose: false,
						shade: 0.5,
						maxmin: true, //开启最大化最小化按钮
						area: ['80%', '90%'],
						content: 'app_list.html?project_id=' + $('.projectid').val(),
						end: function() {},
						success: function() {}
					});
				}
			});
		</script>
	</body>

</html>